﻿using AiXiu.BLL;
using AiXiu.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AiXiu.Web
{
    public partial class Personal : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //读取用户资料 
                TBUsers tBUsers = IdentityManager.ReadUser();
                //显示用户信息
                this.imgAvatar.ImageUrl = tBUsers.Avatar ?? "/imgs/logo.jpg";
                this.lblNickName.Text = tBUsers.NickName ?? $"用户{tBUsers.Id}";
                switch (tBUsers.Sex)
                {
                    case 1:
                        this.lblSex.Text = "猛男";
                        this.lblSex.CssClass += " bg-color-blue";
                        break;
                    case 2:
                        this.lblSex.Text = "小仙女";
                        this.lblSex.CssClass += " bg-color-pink";
                        break;
                    default:
                        this.lblSex.Visible = false;
                        break;

                }
                this.lblAddress.Text = tBUsers.Address ?? "未知地";
                this.lblBirthday.Text = tBUsers.Birthday.HasValue ? tBUsers.Birthday.Value.ToString("M") : "未设置";
                this.lblHobby.Text = tBUsers.Hobby ?? "未添加";
            }
        }

        protected void lbtnLoginOut_Click(object sender, EventArgs e)
        {
            IdentityManager.LoginOut();
            Response.Redirect("Login.aspx");
        }
    }
}